set auto_path [concat [pwd]/../../pkg/tkMD $auto_path ]

package require tkMD
namespace import SimTask::*

if { [llength $argv] == 1 } {
  set protocol [lindex $argv 0]
  if ![file exists $protocol.tcl] { error "Do not have $protocol.tcl under current folder!"}
} else {
   puts "Usage example: $argv0 protol1"
  exit
}

#set up simulatio environment
set SimTask::PdbPath [pwd]/pdb
set SimTask::TemplatePath [pwd]/template
set SimTask::JobPath [pwd]/job
set SimTask::RunPath [pwd]/$protocol
set SimTask::Njobs 16
printEnv

set peptide { 2mag ...}
set type { neutral anionic }
set ionc 0.1
set anfr 0.3
set temp 298
set thick 26
set orientation  o0
set nreplica 4
set com { -20.0 ... 20.0 }
source $protocol.tcl

set com {}
for { set i  $wlo } { $i <= $whi } { set i [expr $i +($whi-$wlo)/($nbins-1)] } {
lappend com $i
}


VarSpace options { peptide type com orientation ionc anfr thick temp}
puts "Has [check_remainning_workpower] CPU left"
# if simulation is only execuate once( as 1 replica ), the path pattern is different from others.
if {$nreplica == 1} {
 ana $SimTask::RunPath eql.dcd traj.inp options [pwd]/$protocol/@peptide/type_@type/com_@com/ --combinejob orientation type --skip { ![file exists eql_min.crd] }
} else { 
 ana $SimTask::RunPath eql.dcd traj.inp options [pwd]/$protocol/@peptide/type_@type/com_@com/run --combinejob orientation type --skip { ![file exists eql_min.crd]}
}

